﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;
using Cafe.BusinessLogic;

namespace Cafe
{
    public partial class LoginForm : DevExpress.XtraEditors.XtraForm
    {
        public string UserName
        {
            get
            {
                return txtUserName.Text;
            }
        }
        public string PassWord
        {
            get
            {
                return txtPassWord.Text;
            }

        }
        public LoginForm()
        {
            InitializeComponent();
        }
        
        private void btnLogin_Click(object sender, EventArgs e)
        {
            SaveConfig();
            this.DialogResult = DialogResult.OK;
        }

        public void SaveConfig()
        {
            Properties.Settings.Default.UserName = txtUserName.Text;
            Properties.Settings.Default.PassWord = txtPassWord.Text;
            Properties.Settings.Default.Remember = cbRemember.Checked;
            Properties.Settings.Default.Save();
        }


        private void frmLogin_Load(object sender, EventArgs e)
        {
            
            if (Properties.Settings.Default.Remember)
            {
                LoadConfig();
            }
            
        }

        private void LoadConfig()
        {
            txtUserName.Text = Properties.Settings.Default.UserName;
            txtPassWord.Text = Properties.Settings.Default.PassWord;
            cbRemember.Checked = true;
        }
    }
}